home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
i·cite - visualizing sources
/
iCite.iso
/
data
/
sp_website2.dir
/
00003_Script_Flash Cursor
< prev
next >
Wrap
Text File
|
2006-06-30
|
8KB
|
255 lines
--******************************************************************************
-- SUMMARY
--******************************************************************************
-- Description: This behavior allows Director to accept a Flash movie's cursor
-- setting. Additionally setting the sprite's cursor property may cause
-- unexpected cursor results. For best results use either the sprite cursor
-- property OR this Flash Cursor behavior.
--
-- Usage:
--
-- 1) Drop this behavior onto a Flash sprite.
--
-- History:
-- 23 Sep 2002. Kraig Mentor. Initial file submission.
--
--
--
--******************************************************************************
-- AUTHOR DEFINED PROPERTIES
--******************************************************************************
-- None.
--******************************************************************************
-- GENERAL PROPERTIES
--******************************************************************************
property pActive ------- Boolean. True if the mouse is within the sprite.
property pFrameCursor -- Integer. The current frame cursor.
property pInitialized -- Boolean. True once the initialization handler has run.
property pMember ------- Member. The member of this sprite.
property pPrevCursor --- Integer. The previous Flash cursor value.
property pSprite ------- Sprite. This sprite.
property pStateOK ------ Boolean. True when the member's initial state
-- is stable.
--******************************************************************************
-- SPRITE HANDLERS
--******************************************************************************
on beginSprite(me)
pSprite = sprite(me.spriteNum)
pMember = pSprite.member
pStateOK = me.isStateOK(pMember, pSprite)
if pStateOK then
pInitialized = me.initialize()
else
pInitialized = FALSE
end if
end
--------------------------------------------------------------------------------
on endSprite(me)
me.restoreCursor()
end endSprite
--******************************************************************************
-- EVENT HANDLERS
--******************************************************************************
on mouseEnter(me)
pActive = TRUE
end mouseEnter
--------------------------------------------------------------------------------
on mouseLeave(me)
pActive = FALSE
me.restoreCursor()
end mouseLeave
--------------------------------------------------------------------------------
on enterFrame(me)
if pStateOK then
if pInitialized then
if pActive then
me.setCursor()
end if
else
pInitialized = me.initialize()
end if
else
pStateOK = me.isStateOK(pMember, pSprite)
end if
end enterFrame
--******************************************************************************
-- CUSTOM HANDLERS
--******************************************************************************
--PURPOSE: Performs initialze set up of the sprite.
--ACCEPTS: 'me' as an instance of this script.
--RETURNS: True.
--EFFECTS: 'pInitialized' gets set.
--------------------------------------------------------------------------------
on initialize(me)
tInitialized = TRUE
pActive = FALSE
pFrameCursor = sprite(0).cursor
if pSprite.cursor <> pFrameCursor then
pPrevCursor = pSprite.cursor
else
pPrevCursor = pFrameCursor
end if
return( tInitialized )
end initialize
--------------------------------------------------------------------------------
--PURPOSE: Verifies that conditions are acceptable for implementation.
--ACCEPTS: 'me' as an instance of this script.
--RETURNS: True if the member has the minimal download reached.
--------------------------------------------------------------------------------
on isStateOK(me, aMember, aSprite)
tStateOK = TRUE
return(tStateOK)
end isStateOK
--------------------------------------------------------------------------------
--PURPOSE: Provides a behavior description in the behavior inspector.
--ACCEPTS: 'me' as a reference to a script member.
--RETURNS: 'tString' as a string.
--------------------------------------------------------------------------------
on restoreCursor(me)
if pPrevCursor <> pFrameCursor then
cursor( pFrameCursor )
pPrevCursor = pFrameCursor
end if
end
--------------------------------------------------------------------------------
on setCursor(me)
tFlashCursor = pSprite.getflashProperty("", #cursor)
-- Return values...
-- 0: No cursor
-- 1: Arrow
-- 2: Hand with finger
-- 3: Hand
-- 4: I Beam
case tFlashCursor of
0: tDirectorCursor = 200
1: tDirectorCursor = -1
2: tDirectorCursor = 280
3: tDirectorCursor = 260
4: tDirectorCursor = 1
otherwise:
tDirectorCursor = pSprite.cursor
end case
if pPrevCursor <> tDirectorCursor then
cursor( tDirectorCursor )
pPrevCursor = tDirectorCursor
end if
end setCursor
--******************************************************************************
-- PREDEFINED HANDLERS
--******************************************************************************
--PURPOSE: Determines whether the behavior can be dropped onto a sprite in the
-- score.
--ACCEPTS: 'me' as a reference to a script member.
-- 'aSpriteType' as a symbol. It indicates the type of sprite attempting
-- to be dropped on to.
-- 'aSpriteNum' as an integer. Indicates the channel of the sprite being
-- dropped on to.
--RETURNS: True if the behavior is allowed to be dropped on the sprite or score,
-- false otherwise.
--------------------------------------------------------------------------------
on isOKtoAttach(me, aSpriteType, aSpriteNum)
if aSpriteType = #graphic then
if sprite(aSpriteNum).member.type = #flash then
return(TRUE)
end if
end if
return(FALSE)
end isOKtoAttach
--------------------------------------------------------------------------------
--PURPOSE: Provides a tooltip in the behavior library palette.
--ACCEPTS: 'me' as a reference to a script member.
--RETURNS: 'tString' as a string.
--------------------------------------------------------------------------------
on getBehaviorToolTip(me)
tString1 = "Allows Director's cursor to obey the Flash movie's cursor setting." & RETURN & RETURN & \
"PERMITTED SPRITE TYPES: Flash." & RETURN & RETURN & \
"USAGE: Apply to a Flash sprite. " & \
"" & RETURN & RETURN & \
"DEPENDENCIES: None."
return(tString1)
end getBehaviorToolTip
--------------------------------------------------------------------------------
--PURPOSE: Provides a behavior description in the behavior inspector.
--ACCEPTS: 'me' as a reference to a script member.
--RETURNS: 'tString' as a string.
--------------------------------------------------------------------------------
on getBehaviorDescription(me)
tString1 = "FLASH CURSOR" & RETURN & RETURN & \
"Drop the behavior onto a Flash sprite to allow Director to maintain the Flash movie's cursor settings." & RETURN & RETURN & \
"Apply this behavior to a Flash sprite." & RETURN & RETURN & \
"PERMITTED MEMBER TYPES:" & RETURN & \
"Flash" & RETURN & RETURN & \
"PARAMETERS:" & RETURN & \
"None."
return(tString1)
end getBehaviorDescription
--******************************************************************************
--******************************************************************************
--******************************************************************************